home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7358 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: airdmhor.gen.nz!not-for-mail
  2. From: gumboot@airdmhor.gen.nz (Simon Hosie)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What's better & why
  5. Date: 26 Feb 1996 10:18:09 +1300
  6. Organization: Airdmhor : a couple of BBS's, a bunch of people, and a cat.
  7. Message-ID: <4gqjmh$dph@airdmhor.gen.nz>
  8. References: <31297C5A.E6C@connix.com> <4gf4s6$fl0@kannews.ca.newbridge.com>
  9. NNTP-Posting-Host: airdmhor.gen.nz
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. > example 1:      val = 1;
  13. >                 if( what ever...)val = 0;
  14. > or 
  15. > example 2:      if( what ever... )val = 0;
  16. >                 else val = 1;
  17.  
  18. Glen Miner:
  19. > If the comiler was dumb, you would get something like the following ASM 
  20. > instructions:
  21. > ...
  22. > So, if I wanted speed, like I usually do, and I was willing to pay the 
  23. > extra few bytes in code size, I'd stay with example 2.
  24.  
  25.   I would suggest example 1, on a 486 a "mov reg, most-things" is only 1
  26. cycle, jumps are 3.  On real computers I would suspect that jumping about
  27. lots (or threatening to jump about lots with conditional jumps) could bother
  28. their pipelining and technical stuff.  Also, real computers have more
  29. registers and can afford to spend them on things like frequently used
  30. variables.
  31.  
  32.  
  33. > Now, I'm no asm genious, and I don't know how smart my compiler is. 
  34.                       ^ <ahem>
  35.